surface: Simplify destroy implementation
authorMatthias Clasen <mclasen@redhat.com>
Sun, 24 Mar 2019 20:24:30 +0000 (16:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 May 2019 20:25:14 +0000 (20:25 +0000)
Without child surfaces, there is no need to recurse.

gdk/broadway/gdksurface-broadway.c
gdk/gdksurface.c
gdk/gdksurfaceimpl.h
gdk/wayland/gdksurface-wayland.c
gdk/x11/gdksurface-x11.c

index 0a1f45567d72f50f650e3a71492555d2607a788c..299c3bff1b280ae46023411ff712b881ccd47eed 100644 (file)
@@ -258,7 +258,6 @@ gdk_surface_broadway_ref_cairo_surface (GdkSurface *surface)
 
 static void
 _gdk_broadway_surface_destroy (GdkSurface *surface,
-                               gboolean   recursing,
                                gboolean   foreign_destroy)
 {
   GdkSurfaceImplBroadway *impl;
index bdec1c608c8827d03c4aa81a5411b87c4c432363..9d9a353e0718d1c51f8c83f67836aeb7c8bb30de 100644 (file)
@@ -636,8 +636,6 @@ surface_remove_from_pointer_info (GdkSurface  *surface,
 /**
  * _gdk_surface_destroy_hierarchy:
  * @surface: a #GdkSurface
- * @recursing: If %TRUE, then this is being called because a parent
- *            was destroyed.
  * @recursing_native: If %TRUE, then this is being called because a native parent
  *            was destroyed. This generally means that the call to the
  *            windowing system to destroy the surface can be omitted, since
@@ -653,8 +651,6 @@ surface_remove_from_pointer_info (GdkSurface  *surface,
  **/
 static void
 _gdk_surface_destroy_hierarchy (GdkSurface *surface,
-                                gboolean   recursing,
-                                gboolean   recursing_native,
                                 gboolean   foreign_destroy)
 {
   GdkSurfaceImplClass *impl_class;
@@ -667,42 +663,32 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
 
   display = gdk_surface_get_display (surface);
 
-  switch (surface->surface_type)
+  if (surface->gl_paint_context)
     {
-    default:
-      g_assert_not_reached ();
-      break;
-
-    case GDK_SURFACE_TOPLEVEL:
-    case GDK_SURFACE_TEMP:
-      if (surface->gl_paint_context)
-        {
-          /* Make sure to destroy if current */
-          g_object_run_dispose (G_OBJECT (surface->gl_paint_context));
-          g_object_unref (surface->gl_paint_context);
-          surface->gl_paint_context = NULL;
-        }
+      /* Make sure to destroy if current */
+      g_object_run_dispose (G_OBJECT (surface->gl_paint_context));
+      g_object_unref (surface->gl_paint_context);
+      surface->gl_paint_context = NULL;
+    }
 
-      if (surface->frame_clock)
-        {
-          g_object_run_dispose (G_OBJECT (surface->frame_clock));
-          gdk_surface_set_frame_clock (surface, NULL);
-        }
+  if (surface->frame_clock)
+    {
+      g_object_run_dispose (G_OBJECT (surface->frame_clock));
+      gdk_surface_set_frame_clock (surface, NULL);
+    }
 
-      _gdk_surface_clear_update_area (surface);
+  _gdk_surface_clear_update_area (surface);
 
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->destroy (surface, recursing_native, foreign_destroy);
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->destroy (surface, foreign_destroy);
 
-      surface->state |= GDK_SURFACE_STATE_WITHDRAWN;
-      surface->destroyed = TRUE;
+  surface->state |= GDK_SURFACE_STATE_WITHDRAWN;
+  surface->destroyed = TRUE;
 
-      surface_remove_from_pointer_info (surface, display);
+  surface_remove_from_pointer_info (surface, display);
 
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
-      break;
-    }
+  g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
+  g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
 }
 
 /**
@@ -720,7 +706,7 @@ void
 _gdk_surface_destroy (GdkSurface *surface,
                       gboolean   foreign_destroy)
 {
-  _gdk_surface_destroy_hierarchy (surface, FALSE, FALSE, foreign_destroy);
+  _gdk_surface_destroy_hierarchy (surface, foreign_destroy);
 }
 
 /**
@@ -738,7 +724,7 @@ _gdk_surface_destroy (GdkSurface *surface,
 void
 gdk_surface_destroy (GdkSurface *surface)
 {
-  _gdk_surface_destroy_hierarchy (surface, FALSE, FALSE, FALSE);
+  _gdk_surface_destroy_hierarchy (surface, FALSE);
   g_object_unref (surface);
 }
 
index c5bd90ae7c952e512389a9b3926309d088e66fbc..4bae67e914c8491fe691d662ea46ffbfc35354c4 100644 (file)
@@ -100,18 +100,12 @@ struct _GdkSurfaceImplClass
 /* Called to do the windowing system specific part of gdk_surface_destroy(),
  *
  * surface: The window being destroyed
- * recursing: If TRUE, then this is being called because a parent
- *     was destroyed. This generally means that the call to the windowing
- *     system to destroy the surface can be omitted, since it will be
- *     destroyed as a result of the parent being destroyed.
- *     Unless @foreign_destroy
  * foreign_destroy: If TRUE, the surface or a parent was destroyed by some
  *     external agency. The surface has already been destroyed and no
  *     windowing system calls should be made. (This may never happen
  *     for some windowing systems.)
  */
   void         (* destroy)              (GdkSurface       *surface,
-                                         gboolean         recursing,
                                          gboolean         foreign_destroy);
 
 
index a1088a74df5415c5427e28a4accba1924287d8b4..6b22635fd3997039326a1632520468bd400bbb0e 100644 (file)
@@ -2847,7 +2847,6 @@ gdk_surface_wayland_input_shape_combine_region (GdkSurface           *surface,
 
 static void
 gdk_wayland_surface_destroy (GdkSurface *surface,
-                             gboolean    recursing,
                              gboolean    foreign_destroy)
 {
   GdkWaylandDisplay *display;
index 0da023a09d5deb884b26f57a2317aefe9caf992f..a2b0f421e84b443c143b5d2c364d2a16cfd5e392 100644 (file)
@@ -992,8 +992,7 @@ gdk_toplevel_x11_free_contents (GdkDisplay *display,
 
 static void
 gdk_x11_surface_destroy (GdkSurface *surface,
-                        gboolean   recursing,
-                        gboolean   foreign_destroy)
+                         gboolean    foreign_destroy)
 {
   GdkSurfaceImplX11 *impl = GDK_SURFACE_IMPL_X11 (surface->impl);
   GdkToplevelX11 *toplevel;
@@ -1013,7 +1012,7 @@ gdk_x11_surface_destroy (GdkSurface *surface,
       impl->cairo_surface = NULL;
     }
 
-  if (!recursing && !foreign_destroy)
+  if (!foreign_destroy)
     XDestroyWindow (GDK_SURFACE_XDISPLAY (surface), GDK_SURFACE_XID (surface));
 }